package com.dys.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: 疾风
 * @ClassName: MyServlet
 * @Description: Servlet
 * @CreateDate: 2024/11/21
 * @Version: v1.0.0
 */
@WebServlet(name = "/myServlet",urlPatterns = "/srv.do")
public class MyServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("进入Servlet的doGet方法中......");
        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().println("响应成功!");
        super.doGet(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("进入Servlet的doPost方法中......");
        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().println("响应成功!");
        super.doPost(req, resp);
    }
}
